<?php
require('includes/top.php');
if($_POST['subcat']!='' && $_POST['cat']!='')//query 4 only subcategory selected
{
	
$category=$_POST['cat'];
$country_id=$_POST['con'];
$subcategory=$_POST['subcat'];
$ans=mysql_query("select * from vendors where subcategory_id =".$subcategory." and vendor_category_id=".$category);
//echo 'EXPERT NAME WHO BELONGS TO SELECTED SUB-CATEGORY'.'<br>';
?>
<table width="50%">
<tr>
<td>
	<table border='0' width="100%">
	<tr><th align="left">Vendors</th></tr>
	<?php
	while($res=mysql_fetch_array($ans))
		{
			?>
		<tr>
			<td><a href="#"><?php echo $res['company_name']; ?></a></td>
		</tr>
	<?php
		}
		?>
	</table>
</td>

<td valign="top" align="right">
	<table>
		<tr>
			<th align="left">Featured Experts</th>
		</tr>
		<?php 
			$f_experts=mysql_query("select * from experts where expert_cat_id='3'");
			while($f_rows=mysql_fetch_array($f_experts))
			{ 
		?>
		<tr><td><a href="#"><?php echo $f_rows['company_name']; ?></a></td></tr>
		<?php
			}
		 ?>
	</table>
</td>

</tr>
</table>

<?php
}

elseif($_POST['cat']!='' &&  $_POST['con']=='' && $_POST['subcat']=='')//query 4 only category selected 
{

$category=$_POST['cat'];
$ans=mysql_query("select * from vendors where vendor_category_id=".$category);
//echo 'EXPERT NAME WHO BELONGS TO SELECTED CATEGORY'.'<br>';
?>
<table border='0' width="100%">
<tr><th align="left">vendors</th></tr>
<?php
while($res=mysql_fetch_array($ans))
	{
	?>
	<tr>
		<td><a href="#"><?php echo $res['company_name']; ?></a></td>
	</tr>
<?php
	}
	?>
	</table>
<?php
}

elseif($_POST['cat']!='' && $_POST['con']!='' && $_POST['subcat']!='')//query 4 country,category and sub-category selected
{

$category_id=$_POST['cat'];
$country_id=$_POST['con'];
$subcategory=$_POST['subcat'];

//echo 'EXPERT NAME WHO BELONGS TO THE SELECTED COUNTRY, CATEGORY AND SUB-CATEGORY<br>';
$ans=mysql_query("select * from vendors where vendor_category_id=".$category_id." and country_id=".$country_id." and subcategory_id=".$subcategory);
?>
<table>
<tr>
<td>
	<table border='0' width="100%">
	<tr><th align="left">vendors</th></tr>
	<?php
	while($res=mysql_fetch_array($ans))
		{
		?>
		<tr>
			<td><a href="#"><?php echo $res['company_name']; ?></a></td>
		</tr>
	<?php
		}
		?>
		</table>
</td>

<td valign="top" align="right">
	<table>
		<tr>
			<th align="left">Featured Experts</th>
		</tr>
		<?php 
			$f_experts=mysql_query("select * from experts where expert_cat_id='3'");
			while($f_rows=mysql_fetch_array($f_experts))
			{ 
		?>
		<tr><td><a href="#"><?php echo $f_rows['company_name']; ?></a></td></tr>
		<?php
			}
		 ?>
	</table>
</td>

</tr>
</table>
<?php
}

?>
